#include "stdafx.h"
#ifdef _DEBUG
	#undef THIS_FILE
	static char THIS_FILE[] = __FILE__;
	#define new DEBUG_NEW
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
TCHAR __wnd_text_buffer__[512]={0};
///////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT uiframe_message_nchittest(HWND hWnd,
								 POINT&point,
								 BOOL isMaximized,
								 BOOL canSizing,
								 long wndWidth,
								 long wndHeight,
								 RECT rtSystem[3])
{
	point.x += frame_cxleft;
	point.y += frame_cycaption;
	::ScreenToClient(hWnd,&point);
	for(long i=0;i<3;++i)
	{
		if(PtInRect(&rtSystem[i],point)) return(HTCAPTION);
	}
	if(canSizing&&!isMaximized)
	{
		RECT r={0,0,frame_cxleft,frame_cxleft};
		if(PtInRect(&r,point)) return(HTTOPLEFT);
		SetRect(&r,wndWidth-frame_cxright,0,wndWidth,frame_cxright);
		if(PtInRect(&r,point)) return(HTTOPRIGHT);
		SetRect(&r,0,wndHeight-frame_cybottom,frame_cxleft,wndHeight);
		if(PtInRect(&r,point)) return(HTBOTTOMLEFT);
		SetRect(&r,wndWidth-frame_cxleft,wndHeight-frame_cybottom,wndWidth,wndHeight);
		if(PtInRect(&r,point)) return(HTBOTTOMRIGHT);
		SetRect(&r,0,frame_cxleft,frame_cxleft,wndHeight-frame_cybottom);
		if(PtInRect(&r,point)) return(HTLEFT);
		SetRect(&r,wndWidth-frame_cxright,frame_cxright,wndWidth,wndHeight-frame_cybottom);
		if(PtInRect(&r,point)) return(HTRIGHT);
		SetRect(&r,frame_cxleft,wndHeight-frame_cybottom,wndWidth-frame_cxright,wndHeight);
		if(PtInRect(&r,point)) return(HTBOTTOM);
		SetRect(&r,frame_cxleft,0,wndWidth-frame_cxright,frame_cxleft);
		if(PtInRect(&r,point)) return(HTTOP);
	}
	if(point.y<frame_cycaption) return(HTCAPTION);
	return(HTCLIENT);
}
